require(['./config'],()=>{
    require(['template','header','footer','cookie'],(template)=>{
       
        class Login{
            constructor(){
                this.login()

            }
            login(){
              
                    $(".login").on("click", function() {
                       
                        let phone_num = $(".phone-num").val(),
                            password = $(".password").val();
                      
                        let userList = localStorage.getItem('god')
                        if (userList) {
                            userList = JSON.parse(userList)
                            const isSucc = userList.some(userinfo => {
                                return userinfo.phone_num == phone_num && userinfo.password == password
                            })
                            if (isSucc) {
                                $.cookie('login_user',phone_num, { expires: 2, path: '/' });
                                alert('登录成功，即将跳转首页')
                                $(location).prop('href', '/index.html');

                                

                            } else {
                                alert('用户名或密码错误，请重试');
                                
                                $(".phone-num").val(''),
                               $(".password").val('');
                            }
                        } else  {
                            alert('请先注册');
                            $(location).attr('href', '/html/register.html');
                        }
                    })
                
            }
        }
        new Login

       
            
            })
       
    })